<!DOCTYPE html>
<html lang="UTF-8">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
       <div id="root"></div>
</body>
<style>
    .bg{background-color: blueviolet;}
    .bg1{background-color: chocolate;}
</style>
<script>
    const app = Vue.createApp({
        data() {
            return {
                content : 123,
                inputValue: '',
                contentArray: [],
                name: 'class',
                message:'bg',
                event1: 'mouseout',
                event: 'mouseenter'
            }
        },
        methods: {
            addContentToArray: function() {
                this.contentArray.push(this.inputValue);
            },
            handlerClick(){
                this.message='bg1';
            },
            moveOut(){
                this.message="bg";
            }
        },
        template: 
        `
            <div class="bindbox" @[event]="handlerClick" @[event1]="moveOut" :[name]="message">
                <input v-model="inputValue" />
                <Button @click="addContentToArray">添加{{inputValue}}</Button>      
                <ul>
                    <todo-item v-for="(item , index) of contentArray" 
                        v-bind:item="item" 
                        v-bind:index="index"></todo-item>
                </ul>
                <form action="https://baidu.com" @click.prevent="handlerClick">
                    <button>提交</button>
                </form>
            </div>
        `
    });
    app.component("todo-item",{
        data(){
            return {
                content: ''
            }
        },
        props: ["item", "index"],
        template:
        `
            <li>{{item}} - {{index}}</li>
            
        `
    });
    app.mount("#root");
    
    
</script>
</html>      